package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.OrderOperateHistory;
import com.itheima.mapper.OrderOperateHistoryMapper;
import com.itheima.service.IOrderOperateHistoryService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单操作历史记录 服务实现类
 * </p>
 *
 * @author fukeke
 * @since 2022-11-11
 */
@DubboService
public class OrderOperateHistoryServiceImpl extends ServiceImpl<OrderOperateHistoryMapper, OrderOperateHistory> implements IOrderOperateHistoryService {

    @Autowired
    private OrderOperateHistoryMapper orderOperateHistoryMapper;

    //根据订单id查询订单操作历史记录
    public List<OrderOperateHistory> findOperateHistory(Long orderId) {
        QueryWrapper<OrderOperateHistory> qw = new QueryWrapper<>();
        qw.eq("order_id", orderId);
        return orderOperateHistoryMapper.selectList(qw);
    }

    //批量保存订单操作历史记录
    public void save(List<OrderOperateHistory> historyList) {
        for (OrderOperateHistory history : historyList) {
            orderOperateHistoryMapper.insert(history);
        }
    }

    //保存指定的订单操作历史记录
    public Integer saveOne(OrderOperateHistory history) {
        return orderOperateHistoryMapper.insert(history);
    }
}
